package com.game.message.selfbinary;

import com.game.message.transport.DataBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 接收到数据请求
 *
 * @author lizhiwei
 * @createAt Feb 18, 2015
 */
public class IMResponse {
    private Logger logger = LoggerFactory.getLogger(IMResponse.class);

    protected Header mHeader;
    protected DataBuffer mData;

    public IMResponse() {

    }

    public IMResponse(DataBuffer buffer) {
        decode(buffer);
    }

    public Header getHeader() {
        return mHeader;
    }

    public void setHeader(Header header) {
        mHeader = header;
    }

    public DataBuffer getData() {
        return mData;
    }

    public void setData(DataBuffer data) {
        mData = data;
    }



    /**
     * Length | Header | Actual Content
     *
     * @param buffer
     */
    public void decode(DataBuffer buffer) {
//        if (buffer != null) {
//            try {
//                // length
//                int length = buffer.readInt();
//                // header
//                header = new Header();
//                header.setLength(length);
//                header.decode(buffer, header.getVersion());
//                // data
//                body = buffer.readDataBuffer();
//            } catch (Exception e) {
//                logger.error(e.getMessage());
//            }
//        }
    }
}
